package com.qst.medical.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qst.medical.domain.Professor;
import com.qst.medical.mapper.ProfessorMapper;
import com.qst.medical.param.ProfessorParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: xwg
 * @CreateDate: 2025/7/13
 */

@RequestMapping("/professor")
@RestController
public class ProfessorController {

    @Autowired
    private ProfessorMapper professorMapper;

    @PostMapping("/query")
    public PageInfo<Professor> query(@RequestBody ProfessorParam professorParam) {
// 查询数据库 发出sql请求到数据库
//        使用PageHelper分页工具 分页代码层面不需要动mapper层
        PageHelper.startPage(professorParam.getPageNum(),professorParam.getPageSize());
        List<Professor> professors = professorMapper.dynamicQuery(professorParam);
        PageInfo<Professor> re= new PageInfo<>(professors);
        return re;
    }
}
